﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data.OleDb;
using System.Data;
using DbSharp.Utils.Db;
using DbSharp.Framework.DbObject;
using DbSharp.Framework.Driver.FieldPersistence;

namespace DbSharp.Framework.Driver
{
    /// <summary>
    ///How to: Connect to an Excel Workbook
    ///http://msdn.microsoft.com/en-us/library/cc280527.aspx

    ///Exporting data from SSIS to Excel 2007: Gotchas
    ///http://dougbert.com/blogs/dougbert/archive/2009/02/13/exporting-data-from-ssis-to-excel-2007-gotchas.aspx

    ///2007 Office System Driver: Data Connectivity Components
    ///http://www.microsoft.com/downloads/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en
    /// </summary>
    public class Excel2007OleTestPlugin : ITestDataSource
    {

        private ExcelOleTestPlugin m_ExcelOleTestPlugin = new ExcelOleTestPlugin();

       

        #region ITestDataSource Members

        public DateTime GetDbServerTime(DbConnection conn)
        {
            return m_ExcelOleTestPlugin.GetDbServerTime(conn);
        }

        public bool IsRecordsetTypeArgument(string argumentTypeText)
        {
            return m_ExcelOleTestPlugin.IsRecordsetTypeArgument(argumentTypeText);
        }

        public bool IsRecordsetTypeParameter(DbParameter param)
        {
            return m_ExcelOleTestPlugin.IsRecordsetTypeParameter(param);
        }

        public DbConnection CreateConnection(string connString)
        {
            return m_ExcelOleTestPlugin.CreateConnection(connString);
        }

        public DbCommand PrepareCommand(IStatementDeclaration statement)
        {
            return m_ExcelOleTestPlugin.PrepareCommand(statement);
        }

        public void UpdateCommandText(DbCommand cmd, string newCmdText)
        {
            m_ExcelOleTestPlugin.UpdateCommandText(cmd, newCmdText);
        }

        public void AssignParameterValue(DbParameter param, string value, string dateTimeFormat)
        {
            m_ExcelOleTestPlugin.AssignParameterValue(param, value, dateTimeFormat);
        }

        public bool TransactionSupported
        {

            get
            {
                return m_ExcelOleTestPlugin.TransactionSupported;
            }
        }

        public bool HoldResultsetMustWithNamedArgInSP
        {
            get
            {
                return m_ExcelOleTestPlugin.HoldResultsetMustWithNamedArgInSP;
            }
        }

        public string NormalizeArgumentName(string argumentName)
        {
            return m_ExcelOleTestPlugin.NormalizeArgumentName(argumentName);
        }

   

 
        private IFieldPersistence m_FieldPersistenceService = new Excel2007OleFieldPersistence();
        public IFieldPersistence FieldPersistenceService
        {
            get { return m_FieldPersistenceService; }
        }
        #endregion
    }
}
